
player globalChat format[" PARAM : %1,%2 ",_this select 0,_this select 1];

_clickPos=_this select 0;

_civil=_clickPos nearestObject "Civilian";

for [{_c=0},{_c<(count CivilsDetectingHumans)},{_c=_c+1}]  do
{
		if(_civil in ((CivilsDetectingHumans select _c) select 1))then
		{

            player globalChat format[" Teleport : %1",_civil];
            _civilPos=getPos _civil;
            _civilDir=getDir _civil;

            // camera effect
            _camera = "camera" camCreate [0,0,200];

            _camera camSetPos [(_civilPos select 0)+10,(_civilPos select 1)+10,(_civilPos select 2)+10];
            _camera camSetTarget [(_civilPos select 0),(_civilPos select 1),(_civilPos select 2)+1.5];

            _camera camSetFov 0.700;
            _camera cameraEffect ["internal","back"];
            _camera camCommit 0;

            waitUntil { camCommitted _camera };

            _camera camSetFov 0.50;
            _camera camCommit 5;

            sleep 2;
            
            _civilPos=getPos _civil;    
            
            // replace the camera if the civil moved during the cutscene
            _camera camSetTarget [(_civilPos select 0),(_civilPos select 1),(_civilPos select 2)+1.5];
            _camera camCommit 2;

            _civil setPos [(_civilPos select 0)+100,(_civilPos select 1)+100,0];   

            player setPos _civilPos;
            player setDir _civilDir;

            waitUntil { camCommitted _camera };

            player cameraEffect["terminate","back"];
            camDestroy _camera;

            // wait until the agent died
            waitUntil{ !(alive player) };


            _finalPosPlayer=(getPos player);
            _finalDirPlayer=(getDir player);

            _camera = "camera" camCreate [0,0,200];

            _camera camSetPos [(_finalPosPlayer select 0)+10,(_finalPosPlayer select 1)+10,(_finalPosPlayer select 2)+10];
            _camera camSetTarget [(_finalPosPlayer select 0),(_finalPosPlayer select 1),(_finalPosPlayer select 2)+1.5];

            _camera camSetFov 0.700;
            _camera cameraEffect ["internal","back"];
            _camera camCommit 0;


            player setPos [0,0,0];
            // replace the civil body in the place where the agent were killed
            _civil switchMove "FXStandDip";
            _civil setDamage 1;

            _civil setdir _finalDirPlayer;
            _civil setPos _finalPosPlayer;

            waitUntil{ (alive player) };

            //sleep 2;
            player cameraEffect["terminate","back"];
            camDestroy _camera;


            sleep 60;
            deleteVehicle _civil;

            exit;
		};
};


//if(_civil in CivilsDetectingHumans) then {
    
  

    

//};